package com.sisyphus.simple.data.network;

import com.sisyphus.simple.data.network.model.BaseListResponse;
import com.sisyphus.simple.data.network.model.BaseResponse;
import com.sisyphus.simple.data.network.model.Post;
import com.sisyphus.simple.data.network.model.User;


import java.util.List;

import io.reactivex.rxjava3.core.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;

public interface WebServiceApi {

    @FormUrlEncoded
    @POST("/user/register")
    Observable<BaseResponse<Object>> register(
            @Field("email") String email,
            @Field("password") String password,
            @Field("nickname") String nickname
    );


    @FormUrlEncoded
    @POST("/user/login")
    @Headers("delay-millis:500")
    Observable<BaseResponse<User>> login(
            @Field("email") String email,
            @Field("password") String password
    );


    @POST("/user/info")
    Observable<BaseResponse<User>> info();


    @GET("/post")
    @Headers("delay-millis:1000")
    Observable<BaseListResponse<Post>> list(
            @Query("page") int page,
            @Query("number") int number
    );


    @GET("/post/hot")
    Observable<BaseResponse<List<Post>>> hot();


    @GET("/post/user/favorite")
    Observable<BaseListResponse<Post>> postFavorite(
            @Query("page") int page,
            @Query("number") int number
    );


}
